<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java方法修饰符完全指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border-color: #667eea;
        }
        
        .text-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 12px;
            padding: 1.5rem;
            overflow-x: auto;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        }
        
        .modifier-badge {
            display: inline-block;
            padding: 0.25rem 0.75rem;
            border-radius: 9999px;
            font-size: 0.875rem;
            font-weight: 600;
            transition: all 0.2s ease;
        }
        
        .modifier-badge:hover {
            transform: scale(1.05);
        }
        
        .section-divider {
            height: 2px;
            background: linear-gradient(to right, transparent, #e5e7eb, transparent);
            margin: 3rem 0;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 0.5rem;
            margin-top: 0.25rem;
            font-weight: 700;
            color: #667eea;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        
        .icon-box {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 16px;
            font-size: 24px;
            margin-bottom: 1rem;
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fadeInUp {
            animation: fadeInUp 0.6s ease-out;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center animate-fadeInUp">
            <h1 class="text-5xl md:text-6xl font-bold mb-6">
                Java方法修饰符
                <span class="block text-3xl md:text-4xl mt-4 font-light opacity-90">完全指南</span>
            </h1>
            <p class="text-xl md:text-2xl font-light max-w-3xl mx-auto leading-relaxed">
                深入理解Java中的方法修饰符，掌握访问控制与行为定义的艺术
            </p>
            <div class="mt-10 flex justify-center space-x-6">
                <div class="text-center">
                    <i class="fas fa-lock text-4xl mb-2"></i>
                    <p class="text-sm">访问控制</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-cog text-4xl mb-2"></i>
                    <p class="text-sm">行为定义</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-shield-alt text-4xl mb-2"></i>
                    <p class="text-sm">安全保障</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-6xl mx-auto px-6 py-12">
        
        <!-- Introduction -->
        <section class="bg-white rounded-2xl shadow-xl p-8 mb-12 animate-fadeInUp">
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="drop-cap">在</span>Java编程语言中，方法的修饰符（Modifiers）是控制方法行为和访问权限的关键机制。它们不仅决定了谁可以访问这些方法，还定义了方法的特殊行为和约束。理解并正确使用这些修饰符，是编写高质量、可维护Java代码的基础。
            </p>
        </section>

        <!-- Visual Overview -->
        <section class="bg-white rounded-2xl shadow-xl p-8 mb-12">
            <h2 class="text-3xl font-bold mb-6 text-center text-gradient">修饰符体系概览</h2>
            <div class="mermaid">
                graph TD
                    A[Java方法修饰符] --> B[访问修饰符]
                    A --> C[其他修饰符]
                    
                    B --> D[public]
                    B --> E[protected]
                    B --> F[default]
                    B --> G[private]
                    
                    C --> H[static]
                    C --> I[final]
                    C --> J[synchronized]
                    C --> K[native]
                    C --> L[abstract]
                    C --> M[strictfp]
                    
                    style A fill:#667eea,stroke:#fff,stroke-width:3px,color:#fff
                    style B fill:#764ba2,stroke:#fff,stroke-width:2px,color:#fff
                    style C fill:#764ba2,stroke:#fff,stroke-width:2px,color:#fff
            </div>
        </section>

        <!-- Access Modifiers Section -->
        <section class="mb-12">
            <h2 class="text-4xl font-bold mb-8 text-center">
                <i class="fas fa-key text-purple-600 mr-3"></i>
                访问修饰符
            </h2>
            
            <div class="grid md:grid-cols-2 gap-6">
                <!-- Public -->
                <div class="bg-white rounded-xl shadow-lg p-6 card-hover">
                    <div class="icon-box bg-green-100 text-green-600">
                        <i class="fas fa-globe"></i>
                    </div>
                    <h3 class="text-2xl font-bold mb-3">
                        <span class="modifier-badge bg-green-100 text-green-700">public</span>
                    </h3>
                    <p class="text-gray-700 mb-4">方法可以被任何其他类访问，没有访问限制。</p>
                    <div class="bg-gray-50 rounded-lg p-4">
                        <p class="text-sm text-gray-600">
                            <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
                            <strong>使用场景：</strong>API接口、公共服务方法、需要广泛访问的功能
                        </p>
                    </div>
                </div>

                <!-- Protected -->
                <div class="bg-white rounded-xl shadow-lg p-6 card-hover">
                    <div class="icon-box bg-blue-100 text-blue-600">
                        <i class="fas fa-shield-alt"></i>
                    </div>
                    <h3 class="text-2xl font-bold mb-3">
                        <span class="modifier-badge bg-blue-100 text-blue-700">protected</span>
                    </h3>
                    <p class="text-gray-700 mb-4">方法可以被同包类或任何子类访问。</p>
                    <div class="bg-gray-50 rounded-lg p-4">
                        <p class="text-sm text-gray-600">
                            <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
                            <strong>使用场景：</strong>继承体系中的模板方法、子类需要访问的父类功能
                        </p>
                    </div>
                </div>

                <!-- Default -->
                <div class="bg-white rounded-xl shadow-lg p-6 card-hover">
                    <div class="icon-box bg-yellow-100 text-yellow-600">
                        <i class="fas fa-box"></i>
                    </div>
                    <h3 class="text-2xl font-bold mb-3">
                        <span class="modifier-badge bg-yellow-100 text-yellow-700">default</span>
                    </h3>
                    <p class="text-gray-700 mb-4">包级私有，仅对同一个包中的类可见。</p>
                    <div class="bg-gray-50 rounded-lg p-4">
                        <p class="text-sm text-gray-600">
                            <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
                            <strong>使用场景：</strong>包内协作、内部实现细节、不需要对外暴露的功能
                        </p>
                    </div>
                </div>

                <!-- Private -->
                <div class="bg-white rounded-xl shadow-lg p-6 card-hover">
                    <div class="icon-box bg-red-100 text-red-600">
                        <i class="fas fa-lock"></i>
                    </div>
                    <h3 class="text-2xl font-bold mb-3">
                        <span class="modifier-badge bg-red-100 text-red-700">private</span>
                    </h3>
                    <p class="text-gray-700 mb-4">方法仅能被定义它的类内部访问。</p>
                    <div class="bg-gray-50 rounded-lg p-4">
                        <p class="text-sm text-gray-600">
                            <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
                            <strong>使用场景：</strong>内部实现、辅助方法、隐藏复杂性
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <div class="section-divider"></div>

        <!-- Other Modifiers Section -->
        <section class="mb-12">
            <h2 class="text-4xl font-bold mb-8 text-center">
                <i class="fas fa-cogs text-purple-600 mr-3"></i>
                行为修饰符
            </h2>
            
            <div class="grid md:grid-cols-3 gap-6">
                <!-- Static -->
                <div class="bg-gradient-to-br from-purple-50 to-pink-50 rounded-xl shadow-lg p-6 card-hover">
                    <h3 class="text-xl font-bold mb-3">
                        <span class="modifier-badge bg-purple-200 text-purple-800">static</span>
                    </h3>
                    <p class="text-gray-700 mb-3">属于类本身，而非实例</p>
                    <ul class="text-sm text-gray-600 space-y-1">
                        <li><i class="fas fa-check text-green-500 mr-2"></i>无需创建对象即可调用</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>适合工具类方法</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>不能访问实例变量</li>
                    </ul>
                </div>

                <!-- Final -->
                <div class="bg-gradient-to-br from-blue-50 to-cyan-50 rounded-xl shadow-lg p-6 card-hover">
                    <h3 class="text-xl font-bold mb-3">
                        <span class="modifier-badge bg-blue-200 text-blue-800">final</span>
                    </h3>
                    <p class="text-gray-700 mb-3">不可被重写的方法</p>
                    <ul class="text-sm text-gray-600 space-y-1">
                        <li><i class="fas fa-check text-green-500 mr-2"></i>保证行为不被改变</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>提高安全性</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>可能提升性能</li>
                    </ul>
                </div>

                <!-- Synchronized -->
                <div class="bg-gradient-to-br from-green-50 to-emerald-50 rounded-xl shadow-lg p-6 card-hover">
                    <h3 class="text-xl font-bold mb-3">
                        <span class="modifier-badge bg-green-200 text-green-800">synchronized</span>
                    </h3>
                    <p class="text-gray-700 mb-3">线程安全的方法</p>
                    <ul class="text-sm text-gray-600 space-y-1">
                        <li><i class="fas fa-check text-green-500 mr-2"></i>同一时刻仅一个线程访问</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>防止并发